#define load_evidence
//argument0: newgame.  True if we should zero out the evidence status array.

var c, i;

globalvar evidencecatcount, evidenceitemcounts;
globalvar evidencenames, evidencedescs, evidencestatus;

ini_open("evidence.ini");

evidencecatcount = ini_read_real("summary", "categories", 0);

for(c = 0; c < evidencecatcount; c+=1)
{
    evidenceitemcounts[c] = ini_read_real("category" + string(c), "items", 0);
    
    for(i = 0; i < evidenceitemcounts[c]; i+=1)
    {
        evidencenames[c,i] = ini_read_string("item" + string(c) + "-" + string(i), 
            "name", "Unnamed Evidence");
        evidencedescs[c,i] = ini_read_string("item" + string(c) + "-" + string(i), 
            "description", "This item has not yet been given a description.");
        if(argument0)
        {
            evidencestatus[c,i] = EVIDENCE_UNFOUND;
        }
    }
}
#define initialize_supervisor
globalvar superconfidence, supercred;

superconfidence = 6;
supercred = 3;


#define savedgame_click
if(file_exists("namatjira_" + index + ".sav"))
{
    loadSavedGame("namatjira_" + index + ".sav");
    
    room_goto(PlanetView);
}
else
{
    createNewGame(index);
    
    room_goto(SceneOpening);
}
#define savedgame_draw
var name;

if(file_exists("namatjira_" + index + ".sav"))
{
    ini_open("namatjira_" + index + ".sav");
    name = ini_read_string("Meta","Name","Unnamed Save");
    ini_close();
}
else
{
    name = "New Save";
}

draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_color(c_black);
draw_text(x+64, y+64, name);

#define loadSavedGame
var filename;

filename = argument0;

ini_open(filename);

global.playerName = ini_read_string("Meta", "Name", "Technician");

global.currentDay = ini_read_real("Time", "currentDay", 0);

//TODO: Open and process INI save file
#define createNewGame
var name;
var index;

index = argument0;

name = get_string("What is your name?","Player " + index);

ini_open("namatjira_" + index + ".sav");

global.playerName = name;
ini_write_string("Meta","Name",playerName);

global.currentDay = 0;
ini_write_real("Time","currentDay", currentDay);

ini_close();
#define planethandler_click
var xindex, yindex;

xindex = floor((mouse_x - 16) / 32);
yindex = floor((mouse_y - 16) / 32);

room_goto(LocalView);

populateLocalView(xindex, yindex);
#define planetbutton_click
room_goto(PlanetView);
advancetime();
#define advancetime

global.currentDay = global.currentDay + 1;

if(global.currentDay mod 10 == 0)
{
    room_goto(Communication);
}
#define populateLocalView
show_message("" + string(argument0) + ", " + string(argument1));
#define clock_draw
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_color(c_red);
draw_text(x+48, y+16, "Day " + string(global.currentDay));
